<?php
/**
 * Created by PhpStorm.
 * User: lyon
 * Date: 16-12-10
 * Time: 下午12:16
 * 写数据库
 */
include_once 'function/Config.php';
include_once 'function/Mysql.php';
include_once 'function/Preg.php';
include_once 'function/Log.php';
include_once 'function/Count.php';

Mysql::_init();
Log::_init();
Count::_writeInit();
$table = $GLOBALS['db']['name'];
$field = '';

$exit = 1;
while($exit)
{
    $arr = array('issearch' => '1');
    if (empty($searchName = Mysql::findOne($arr, $field, $table)))
    {
        Count::$INFO['have_user'] = 0;
    }
    else
    {
        Count::$INFO['have_user'] = 1;
        Mysql::upDateOne(array('issearch' => '3'), array('id' => "{$searchName['id']}"), $table);
        if (!empty($user = Preg::getUserInfo($searchName['u_name'])))
        {
            Mysql::upDateOne($user, array('id' => "{$searchName['id']}"), $table);
            Count::$INFO['write_success']++;
        }
        else
        {
            Count::$INFO['write_error']++;
        }
        if (!empty($user = Preg::pregDetail($searchName['u_name'])))
        {
            Mysql::upDateOne($user, array('id' => "{$searchName['id']}"), $table);
            Count::$INFO['write_success']++;
        }
        else
        {
            Count::$INFO['write_error']++;
        }
    }
    Count::$INFO['now_time'] = date('Y-m-d H:i:s');
    Count::writeShow();
}
